package com.bpc.cs.dto;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.bpc.cs.constant.DBConstant;

/**
 * @author phan_tp
 * @since Nov 30, 2012 : 1:20:50 PM
 */

@Entity
@Table (name = DBConstant.TBL_SCORING_SCHEME)
public class SchemeDTO {

	@Id
	@SequenceGenerator(name = "generator_scheme", sequenceName = "scheme_id_seq",
					   catalog = "CREDIT_SCORING", schema = "SCREDIT_SCORING", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator_scheme")
	@Column (name = DBConstant.COL_SS_ID, unique = true, nullable = false)
	private int schemeID;

	@Column (name = DBConstant.COL_SS_NAME, unique = true, nullable = false)
	private String schemeName;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "schemeDTO")
	@Cascade(CascadeType.ALL)
	@Fetch(FetchMode.SELECT)
	private Set<RuleDTO> ruleDTO;

	/**
	 * Main contructor init object without any initialization of property
	 */
	public SchemeDTO() {}

	/**
	 * Contructor init name of scheme
	 * @param String schemeName
	 */
	public SchemeDTO(final String schemeName) {
		this.schemeName = schemeName;
	}

	/**
	 * Contructor init ID and name of scheme
	 * @param int schemeID
	 * @param String schemeName
	 */
	public SchemeDTO(final int schemeID, final String schemeName) {
		this.schemeName = schemeName;
	}

	/**
	 * @return the schemeID
	 */
	public int getSchemeID() {
		return schemeID;
	}

	/**
	 * @param int schemeID
	 */
	public void setSchemeID(int schemeID) {
		this.schemeID = schemeID;
	}

	/**
	 * @return String schemeName
	 */
	public String getSchemeName() {
		return schemeName;
	}

	/**
	 * @param String schemeName
	 */
	public void setSchemeName(String schemeName) {
		this.schemeName = schemeName;
	}

	/**
	 * @return the ruleDTO
	 */
	public Set<RuleDTO> getRuleDTO() {
		return ruleDTO;
	}

	/**
	 * @param ruleDTO the ruleDTO to set
	 */
	public void setRuleDTO(Set<RuleDTO> ruleDTO) {
		this.ruleDTO = ruleDTO;
	}

}
